/*
 * User: Sepheus Angelus
 * Date: 12/03/2008
 * Time: 08:01
 * 
 */

using System;
using System.Collections.Generic;

namespace Aphyros_MUD_Server
{
	/// <summary>
	/// Holds data for each room.
	/// </summary>
	public class Rooms
	{
		/// <summary>
		/// Unique ID of the Room.
		/// </summary>
		public static List<int> RoomID = new List<int>();
		/// <summary>
		/// Description associated with the Room.
		/// </summary>
		public static List<string> Description = new List<string>();
		/// <summary>
		/// Northern Room.
		/// </summary>
		public static List<int> North = new List<int>();
		/// <summary>
		/// Eastern Room.
		/// </summary>
		public static List<int> East = new List<int>();
		/// <summary>
		/// Southern Room.
		/// </summary>
		public static List<int> South = new List<int>();
		/// <summary>
		/// Western Room.
		/// </summary>
		public static List<int> West = new List<int>();
		
		
		/// <summary>
		/// Describes the Room to the user.
		/// </summary>
		/// <param name="user">User to describe the Room to.</param>
		public static void Describe(Listener user)
		{
			user.Writer.Write(ANSI.BrightBlue);
			user.Writer.WriteLine(Rooms.Description[user.Room]);
			user.Writer.Write(ANSI.White);
		}
		
		/// <summary>
		/// Moves the user in the desired direction if it is possible.
		/// </summary>
		/// <param name="Direction">The direction the user wishes to go.</param>
		/// <param name="user">The user that wishes to be moved.</param>
		public static void Move(string Direction, Listener user)
		{
			List<int> Dir = new List<int>();
			Direction = Direction.ToLower();
			switch(Direction)
			{
				case "north":
					Dir = Rooms.North;
					break;
				case "south":
					Dir = Rooms.South;
					break;
				case "east":
					Dir = Rooms.East;
					break;
				case "west":
					Dir = Rooms.West;
					break;
				default:
					break;
			}
			int NewRoom = Rooms.RoomID[Dir[user.Room]];
			if( NewRoom != 0)
			{
				user.Room = NewRoom;
				Rooms.Describe(user);
			}
			else
			{
				user.Writer.Write(ANSI.BrightRed);
				user.Writer.WriteLine("You can not go that way!");
				user.Writer.Write(ANSI.White);
			}
		}
	}
}
